home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Amazon.de.ifs < prev    next >
Text File  |  2005-03-13  |  8KB  |  220 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=haluto
  8. Title=Amazon.de (Image Only)
  9. Description=Amazon.de picture import (large picture O N L Y)
  10. Site=http://www.amazon.de
  11. Language=DE
  12. Version=19.02.2005
  13. Requires=3.5.0
  14. Comments=haluto@web.de|Based on Grasmo's Superscript and| - IMDB script| - OMDb/IMDB script| - Amazon (US & DE) script|don't forget the credits of the original scripts - they did most of the work!
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program AmazonPictureImport_DE;
  23.  const
  24. //Set this to False if you wish to pick the Amazon Picture manual (german or english)
  25.   AutomaticAmazonPicPick = FALSE;
  26. //Set this to False if you wish the script not automize everything
  27.   TotalAutomatic = FALSE;
  28.  
  29. var
  30.  MovieName, Amazon_num: string;
  31.  TheMovieTitle: string;
  32.  TheMovieAddress: string;
  33.  OMDb_link: string;
  34.  
  35. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  36.  var
  37.   i: Integer;
  38. begin
  39.  result := -1;
  40.  if StartAt < 0 then
  41.   StartAt := 0;
  42.  for i := StartAt to List.Count-1 do
  43.   if Pos(Pattern, List.GetString(i)) <> 0 then
  44.    begin
  45.     result := i;
  46.     Break;
  47.    end;
  48. end;
  49.  
  50. function GetToken(aString, SepChar: String; TokenNum: Integer):String;
  51.  var
  52.   Token     : string;
  53.   StrLen    : Integer;
  54.   TNum      : Integer;
  55.   TEnd      : Integer;
  56. begin
  57.  StrLen := Length(aString);
  58.  TNum   := 1;
  59.  TEnd   := StrLen;
  60.  while ((TNum <= TokenNum) and (TEnd <> 0)) do
  61.   begin
  62.    TEnd := Pos(SepChar,aString);
  63.    if TEnd <> 0 then
  64.     begin
  65.      Token := Copy(aString,1,TEnd-1);
  66.      Delete(aString,1,TEnd);
  67.      TNum := TNum + 1;
  68.     end
  69.    else
  70.     Token := aString;
  71.   end;
  72.  if TNum >= TokenNum then
  73.   GetToken := Token
  74.  else
  75.   GetToken := '';
  76. end;
  77.  
  78. function AsinParse(Line : string): string;
  79. begin
  80.  Result := GetToken(GetToken(Line,'.',2),Chr(34),1);
  81. end;
  82.  
  83. procedure GetAmazonPic;
  84.  var
  85.   LineNr, I: Integer;
  86.   AmazonPage, AmazonPageNOHTML: TStringList;
  87.   AmazonPage2, AmazonPageNOHTML2: TStringList;
  88.   TempHold, TempHold2, THolder: string;
  89.   FoundSomething: integer;
  90.   mov, dlink: string;
  91.   TheLink: string;
  92. begin
  93.   dlink := '';
  94.   TheLink := '';
  95.   mov := GetField(fieldTranslatedTitle);
  96.   if mov = '' then
  97.    begin
  98.     mov := GetField(fieldOriginalTitle);
  99.     if mov = '' then
  100.      mov := MovieName;
  101.    end;
  102.   FoundSomething := 1;
  103.   AmazonPage := TStringList.Create;
  104.   AmazonPage.Text := GetPage('http://www.amazon.de/exec/obidos/search-handle-url/index=dvd-de&field-title=' + StringReplace(UrlEncode(mov),'+', '%20'));
  105.   PickTreeClear;
  106.   if FindLine('Infos zu diesem Titel',AmazonPage,1) <> -1 then
  107.    begin
  108.     PickTreeAdd('Amazon(DE) Pictures fⁿr [' + mov + ']','');
  109.     LineNr := FindLine('<input type="hidden" name="asin.',AmazonPage,1);
  110.     dlink := 'http://images-eu.amazon.com/images/P/' + AsinParse(AmazonPage.Getstring(LineNr)) + '.03.LZZZZZZZ.jpg';
  111.     PickTreeAdd(mov, dlink);
  112.    end;
  113.   if FindLine('Wir haben keine genauen Treffer fⁿr Ihre Suche fⁿr ',AmazonPage,1) <> -1 then
  114.    FoundSomething := 0;
  115.   if (FindLine('Die besten Treffer',AmazonPage,1) <> -1) OR (FindLine('Alle Ergebnisse fⁿr',AmazonPage,1) <> -1) then
  116.    begin
  117.     I := 1;
  118.     PickTreeAdd('Amazon(DE) Pictures fⁿr [' + mov + ']','');
  119.     while (i <= AmazonPage.Count-1) do
  120.      begin
  121.       THolder := AmazonPage.GetString(i);
  122.       HTMLRemoveTags(THolder);
  123.       if (Pos('/exec/obidos/ASIN/',AmazonPage.GetString(i)) <> 0) and (THolder <> '') and (Pos('Preis: EUR',AmazonPage.GetString(i)) = 0) and (Pos('THUMBZZZ',AmazonPage.GetString(i)) = 0) then
  124.        PickTreeAdd(THolder,'http://images-eu.amazon.com/images/P/' + GetToken(AmazonPage.GetString(i),'/',5) + '.03.LZZZZZZZ.jpg');
  125.       if THolder = mov then
  126.        dlink := 'http://images-eu.amazon.com/images/P/' + GetToken(AmazonPage.GetString(i),'/',5) + '.03.LZZZZZZZ.jpg';
  127.       i := i + 1;
  128.      end
  129.    end;
  130.   If AutomaticAmazonPicPick and (dlink <> '') then
  131.    begin
  132.     GetPicture(dlink);
  133.     exit;
  134.    end;
  135.   mov := GetField(fieldOriginalTitle);
  136.   if mov = '' then
  137.    begin
  138.     mov := GetField(fieldTranslatedTitle);
  139.     if mov = '' then
  140.      mov := MovieName;
  141.    end;
  142.   AmazonPage2 := TStringList.Create;
  143.   AmazonPage2.Text := GetPage('http://www.amazon.com/exec/obidos/search-handle-url/index=dvd&field-title=' + StringReplace(UrlEncode(GetField(fieldOriginalTitle)),'+', '%20'));
  144.   AmazonPageNOHTML2 := TStringList.Create;
  145.   AmazonPageNOHTML2.Text := AmazonPage2.Text;
  146.   TempHold2 := AmazonPageNOHTML2.Text;
  147.   HTMLRemoveTags(TempHold2);
  148.   AmazonPageNOHTML2.Text := TempHold2;
  149.   if FindLine('Amazon.com: DVD:',AmazonPage2,1) <> -1 then
  150.    begin
  151.     LineNr := FindLine('<input type="hidden" name="asin.',AmazonPage2,1);
  152.     if FoundSomething = 0 then
  153.      begin
  154.       GetPicture('http://images.amazon.com/images/P/' + AsinParse(AmazonPage2.Getstring(LineNr)) + '.01.LZZZZZZZ.jpg');
  155.       exit;
  156.      end
  157.     else
  158.      begin
  159.       PickTreeAdd('Amazon(US) Pictures fⁿr [' + mov + ']','');
  160.       PickTreeAdd(mov, 'http://images.amazon.com/images/P/' + AsinParse(AmazonPage2.Getstring(LineNr)) + '.01.LZZZZZZZ.jpg');
  161.      end;
  162.    end;
  163.    if FindLine('DVD Search Results: we were unable to find exact matches for your search for',AmazonPage,1) <> -1 then
  164.     if FoundSomething = 0 then
  165.      exit;
  166.    if (FindLine('Below are results for',AmazonPage2,1) <> -1) OR (FindLine('All results',AmazonPage2,1) <> -1) OR (FindLine('Most popular results for',AmazonPage2,1) <> -1) then
  167.     begin
  168.      I := 1;
  169.       PickTreeAdd('Amazon(US) Pictures fⁿr [' + mov + ']','');
  170.      while (i <= AmazonPage2.Count-1) do
  171.       begin
  172.        THolder := AmazonPage2.GetString(i);
  173.        HTMLRemoveTags(THolder);
  174.        if (Pos('/exec/obidos/ASIN/',AmazonPage2.GetString(i)) <> 0) and (THolder <> '') and (Pos('Buy new',AmazonPage2.GetString(i)) = 0) and (Pos('Used & new from',AmazonPage2.GetString(i)) = 0) and (Pos('THUMBZZZ',AmazonPage2.GetString(i)) = 0) then
  175.         begin
  176.          PickTreeAdd(THolder,'http://images.amazon.com/images/P/' + GetToken(AmazonPage2.GetString(i),'/',5)+ + '.01.LZZZZZZZ.jpg');
  177.          if THolder = mov then
  178.           dlink := 'http://images.amazon.com/images/P/' + GetToken(AmazonPage2.GetString(i),'/',5)+ + '.01.LZZZZZZZ.jpg';
  179.         end;
  180.        if (Pos('/exec/obidos/tg/detail/',AmazonPage2.GetString(i)) <> 0) and (THolder <> '') and (Pos('Buy new',AmazonPage2.GetString(i)) = 0) and (Pos('Used & new from',AmazonPage2.GetString(i)) = 0) and (Pos('THUMBZZZ',AmazonPage2.GetString(i)) = 0) and (Pos('http://www.amazon.com',AmazonPage.GetString(i)) = 0) and (Pos('In-store Pickup',AmazonPage.GetString(i)) = 0) then
  181.         begin
  182.          PickTreeAdd(THolder,'http://images.amazon.com/images/P/' + GetToken(AmazonPage2.GetString(i),'/',7)+ + '.01.LZZZZZZZ.jpg');
  183.          if THolder = mov then
  184.           dlink := 'http://images.amazon.com/images/P/' + GetToken(AmazonPage2.GetString(i),'/',7)+ + '.01.LZZZZZZZ.jpg';
  185.         end;
  186.        i := i + 1;
  187.       end
  188.     end
  189.   If AutomaticAmazonPicPick and (dlink <> '') then
  190.    begin
  191.     GetPicture(dlink);
  192.     exit;
  193.    end;
  194.   if TotalAutomatic and (dlink <> '') then
  195.    GetPicture(dlink)
  196.   else
  197.    if PickTreeExec(THolder) then
  198.     GetPicture(THolder);
  199. end;
  200.  
  201. begin
  202.  if CheckVersion(3,5,0) then
  203.    begin
  204.    OMDb_link := '';
  205.    TheMovieTitle:='';
  206.    TheMovieAddress:='';
  207.    MovieName := GetField(fieldTranslatedTitle);
  208.    if MovieName = '' then
  209.     begin
  210.      MovieName := GetField(fieldOriginalTitle);
  211.      if MovieName = '' then
  212.       Input('Movie Title', 'Bitte Titel eingeben :', MovieName);
  213.     end;
  214.    GetAmazonPic;
  215.    //DisplayResults;
  216.   end
  217.  else
  218.   ShowMessage('Dieses Script ben÷tigt eine neuere Version von Ant Movie Catalog (mindestens Version 3.5.0)');
  219. end.
  220.